package com.mdd.front.controller;

import com.mdd.common.core.AjaxResult;
import com.mdd.front.vo.wxpay.CustomizeWxJsapiSignature;
import me.chanjar.weixin.common.bean.WxJsapiSignature;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author panweiliang
 */
@RestController
@RequestMapping("/api/wx")
public class WxController {

    @Autowired
    private WxMpService wxMpService;

    @GetMapping("/jssdk/valid")
    public Object valid() throws WxErrorException {
        WxJsapiSignature wxJsapiSignature = this.wxMpService.createJsapiSignature("");
        CustomizeWxJsapiSignature customizeWxJsapiSignature = new CustomizeWxJsapiSignature();
        BeanUtils.copyProperties(wxJsapiSignature, customizeWxJsapiSignature);
        return AjaxResult.success(customizeWxJsapiSignature);
    }

}

